package com.woniuxy.educationplatform.controller;

import com.woniuxy.educationplatform.bean.SubjectBean;
import com.woniuxy.educationplatform.service.IProjectService;
import com.woniuxy.educationplatform.service.ISubjectService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/subject")

public class SubjectController {

    @Resource
    private IProjectService projectServiceImpl;
    @Resource
    private ISubjectService subjectServiceImpl;

    @RequestMapping("findAll")
    public List<SubjectBean> findAll(){
        System.out.println("我进入到查询了");
        return subjectServiceImpl.findAll();

    }
    @RequestMapping(value ="/findOneByCondition",produces = {"application/json;charset=utf-8"})
    public List<SubjectBean> findOneByCondition(Long id, @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date createTime){
        System.out.println("开始根据条件查询");
        System.out.println(id);
        System.out.println(createTime);
        List<SubjectBean> list=subjectServiceImpl.findOneByCondition(id,createTime);
        for (SubjectBean a:list
             ) {
            System.out.println(a);

        }


        return list;
    }

    @RequestMapping("/getsubject")
    public String[] getSubject(){
        return subjectServiceImpl.getSubjectName();
    }
}
